/*     */ package com.qmsk.business.wechat.controller;
/*     */ 
/*     */ import com.qmsk.business.wechat.bean.OAuthCache;
/*     */ import com.qmsk.business.wechat.service.WechatService;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.PrintWriter;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"wechat"})
/*     */ public class WechatController
/*     */ {
/*  25 */   Logger logger = Logger.getLogger(WechatController.class);
/*     */ 
/*     */   @Autowired
/*     */   private WechatService service;
/*     */ 
/*     */   @RequestMapping({"/handle/textmessage"})
/*     */   public void textMessageHandler(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  42 */       String openId = RequestUtils.getString(request, "openId");
/*  43 */       String text = RequestUtils.getString(request, "text");
/*     */ 
/*  45 */       this.logger.debug("OpenId:" + openId);
/*  46 */       this.logger.debug("Text:" + text);
/*     */ 
/*  48 */       if ((openId == null) || (text == null)) {
/*  49 */         return;
/*     */       }
/*     */ 
/*  53 */       if (!("欢迎语".equals(text))) {
/*  54 */         this.service.saveTextInfo(openId, text);
/*     */       }
/*     */ 
/*  57 */       this.service.sendKeyWordReplyMessage(openId, text);
/*     */ 
/*  59 */       PrintWriter out = response.getWriter();
/*  60 */       out.print("");
/*     */     }
/*     */     catch (Exception e) {
/*  63 */       this.logger.error("文本消息处理失败，错误信息：" + e);
/*  64 */       this.logger.error("文本消息处理失败，错误信息：" + e.getMessage());
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping({"/subscribe/{openId}"})
/*     */   public void subscribe(HttpServletRequest request, HttpServletResponse response, @PathVariable("openId") String openId)
/*     */   {
/*     */     try
/*     */     {
/*  73 */       Long localLong = Long.valueOf(280000022L);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*  81 */       DbConnection.rollback();
/*  82 */       this.logger.error("关注事件处理失败，错误信息：" + e);
/*  83 */       this.logger.error("关注事件处理失败，错误信息：" + e.getMessage());
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping({"interactive"})
/*     */   public void interactive(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  91 */     String openId = RequestUtils.getString(request, "openId");
/*  92 */     this.logger.debug("OpenId: " + openId);
/*  93 */     if (this.service.sendSubMessage(openId))
/*  94 */       this.logger.debug("send subscribe message successed.");
/*     */     else
/*  96 */       this.logger.error("send subscribe message failed.");
/*     */   }
/*     */ 
/*     */   @RequestMapping({"accessToken/{code}"})
/*     */   public void getAccessToken(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code)
/*     */   {
/*     */     try
/*     */     {
/* 104 */       String openId = OAuthCache.getOpenId(code);
/* 105 */       ResponseUtils.toGsonEbRst(new String[] { "openId" }, 
/* 106 */         new Object[] { openId }, response);
/*     */     } catch (Exception e) {
/* 108 */       this.logger.error(e);
/* 109 */       ResponseUtils.setErrorMsgResponse(
/* 110 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.wechat.controller.WechatController
 * JD-Core Version:    0.5.3
 */